//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package messages;

import commands.LogicCommand;
import common.ByteStream;
import common.Logger;
import common.StringUtils;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class EndClientTurn extends Base {
    private static final int MsgType = 14102;
    private final List<LogicCommand> cmds;
    private final Integer lastTick;
    private boolean showBinaryData = false;

    public EndClientTurn(Integer tick) {
        super(14102);
        this.version = 0;
        this.lastTick = tick;
        this.cmds = new ArrayList();
    }

    public EndClientTurn(List<LogicCommand> cmds, Integer tick) {
        super(14102);
        this.version = 0;
        this.lastTick = tick;
        this.cmds = cmds;
    }

    public void addLogicCommand(LogicCommand lc) {
        this.cmds.add(lc);
    }

    public void encode(ByteStream stream) {
        stream.writeInt(this.lastTick.intValue());
        stream.writeByte((byte)this.cmds.size());
        Iterator var3 = this.cmds.iterator();

        while(var3.hasNext()) {
            LogicCommand lc = (LogicCommand)var3.next();
            lc.encode(stream);
        }

        if(this.showBinaryData) {
            if(this.cmds.size() > 0) {
                System.out.println(Logger.formatPT("EndClientTurn", "  " + StringUtils.dumpBytes(stream.getCopyOfByteArray())));
            } else {
                System.out.println(Logger.formatPT("EndClientTurn", "  empty"));
            }
        }

    }

    public void decode(ByteStream stream) {
    }

    public String toString() {
        ByteStream stream = new ByteStream(100);
        this.encode(stream);
        return StringUtils.dumpBytes(stream.getCopyOfByteArray());
    }
}
